﻿<helpers:BindablePage
    x:Class="BalanceManager.MainPage"
    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=MainViewModel}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helpers="clr-namespace:BalanceManager.Helpers"
    xmlns:bar="clr-namespace:BindableApplicationBar;assembly=BindableApplicationBar"
    xmlns:converters="clr-namespace:BalanceManager.Helpers.Converters"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!-- Animated page transition -->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn" />
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn" />
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut" />
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <helpers:BindablePage.Resources>
        <converters:FlowTypeToColorConverter x:Key="flowTypeToColorConverter" />
    </helpers:BindablePage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <!-- LOCALIZATION NOTE:
            To localize the displayed strings copy their values to appropriately named
            keys in the app's neutral language resource file (AppResources.resx) then
            replace the hard-coded text value between the attributes' quotation marks
            with the binding clause whose path points to that string name.

            For example:

                Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

            This binding points to the template's string resource named "ApplicationTitle".

            Adding supported languages in the Project Properties tab will create a
            new resx file per language that can carry the translated values of your
            UI strings. The binding in these examples will cause the value of the
            attributes to be drawn from the .resx file that matches the
            CurrentUICulture of the app at run time.
         -->

        <phone:Pivot Title="менеджер">
            <phone:PivotItem Header="сегодня">
                <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding FundFlows}" ItemRealized="LongListSelector_ItemRealized" ItemUnrealized="LongListSelector_ItemUnrealized">
                    <phone:LongListSelector.ItemTemplate>
                        <DataTemplate> 
                            <StackPanel Margin="0,0,0,17">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="50" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <Border Grid.Row="0" Background="{Binding FlowType, Converter={StaticResource flowTypeToColorConverter}}"  Height="50" Width="50" VerticalAlignment="Center" />
                                    <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding ItemName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
                                    <TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding Amount, StringFormat=F2}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" />
                                </Grid>
                            </StackPanel>
                        </DataTemplate>
                    </phone:LongListSelector.ItemTemplate>
                </phone:LongListSelector>
            </phone:PivotItem>
        </phone:Pivot>
        <Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100"/>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" IsHitTestVisible="False" />-->
    </Grid>

    <bar:Bindable.ApplicationBar>
        <bar:BindableApplicationBar>
            <bar:BindableApplicationBarButton Command="{Binding AddExpenseCommand}" IconUri="/Images/minus.png" Text="Расход" />
            <bar:BindableApplicationBarButton Command="{Binding AddProfitCommand}" IconUri="/Images/add.png" Text="Прибыль" />
            <bar:BindableApplicationBarButton Command="{Binding ItemsCommand}" IconUri="/Images/edit.png" Text="Категории" />
            <bar:BindableApplicationBarButton Command="{Binding HistoryCommand}" IconUri="/Images/feature.calendar.png" Text="История" />
        </bar:BindableApplicationBar>
    </bar:Bindable.ApplicationBar>

</helpers:BindablePage>